<?php
declare (strict_types=1);

namespace app\api\controller\v1;

use app\common\model\Record as RecordModel;

class Record
{
    /**
     * 个人中心--历史答卷
     */
    public function index()
    {
        return sucessMsg(200, '获取成功', [
            'record' => $this->record(),   //获取历史答卷
        ]);
    }

    /**
     * 个人中心--历史答卷
     */
    public function record()
    {
        $data = RecordModel::where(['status'=>1])
            ->field('id,paper_id,exam_time,end_time')
            ->order(['id' => 'asc'])
            ->select();
        foreach ($data as &$value) {
            $value['paper_id'] = $value->paper->title;
            unset($value->paper);
            $value['end_time'] = date('Y-m-d H:i:s', $value['end_time']);

        }
        return $data;
    }





}
